package com.example.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class HomeFragment extends Fragment {
    private TextView tvTworv;
    private RecyclerView rvTj1;
    private int[] tupian = {R.drawable.dangjian,R.drawable.chengshi,R.drawable.csyj,R.drawable.dangjian1,R.drawable.paoche};
    private String[] wenzi = {"九月的故宫，新展连连，近日，由于故宫博物院...","中国国家铁路集团有限公司最新数据显示，全...",
            "城市的夜景是你所向往的吗","党建活动多参加","跑车应该是每个男孩子所想拥有的吧"};
    private TextView tvMainFuwu;
    private RecyclerView rvTj;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View inflate = inflater.inflate(R.layout.fragment_home_fragmet, container, false);
        initView(inflate);
        List<Info> list = new ArrayList<>();
        list.add(new Info("城市地铁", R.drawable.subway));
        list.add(new Info("智慧巴士", R.drawable.bus));
        list.add(new Info("门诊预约", R.drawable.yuyue));
        list.add(new Info("生活缴费", R.drawable.live));
        list.add(new Info("违章查询", R.drawable.search));

//        View view = inflater.inflate(R.layout.tworv_item,container,false);
//        initView(view);
//        rvTj1.setLayoutManager(new LinearLayoutManager(getContext()));
//        SecondRvAd adapter = new SecondRvAd(tupian,wenzi);
//        rvTj1.setAdapter(adapter);


        RvAd rvAd = new RvAd(list, getResources());
        rvTj.setAdapter(rvAd);
        rvTj.setLayoutManager(new GridLayoutManager(getContext(), 5));
        return inflate;

    }




    private void initView(View view) {
        rvTj1 = (RecyclerView) view.findViewById(R.id.rvTj1);
        tvTworv = (TextView) view.findViewById(R.id.tv_twoRv);
        tvMainFuwu = (TextView) view.findViewById(R.id.tv_main_fuwu);
        rvTj = (RecyclerView) view.findViewById(R.id.rvTj);

    }
}